#include("/template/common/layout/_page_layout.html") #@layout() #define css()
<style>
    button {
        background: #758ef0;
        color: #FFF;
        border: none;
        border-radius: 15px;
    }

    .layui-input {
        width: 350px;
    }

    .layui-btn {
        margin-left: 150px;
    }
</style>

#end
  #define content()
<div class="layui-fluid">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;color: #009688">
        <legend style="font-size: 20px;font-weight: 500;">企业机构认证</legend>
    </fieldset>
    <div style="width: 1100px; position: relative; left:5%;padding: 50px 0px 0px 0px;">
        <form id="person" class="layui-form" action="">
            <div class="layui-form-pane">
                <div class="layui-row">
                    <div class="layui-col-md6">
                        <div class="grid-demo grid-demo-bg1">
                            <div class="layui-form-item">
                                <label class="layui-form-label" for="organization.name" style="width: 180px">组织机构名称</label>
                                <div class="layui-input-block " style="margin: 0 180px">
                                    <input type="text" id="organization.name" name="organization.name" placeholder="#(organization.name)" value="#(organization.name)" class="layui-input " style="width: 300px" readonly/>
                                </div>
                            </div>

                            <div class="layui-form-item">
                                <label class="layui-form-label" for="enterprise.name" style="width: 180px"> <em class="require-mark">*</em>企业机构名称</label>
                                <div class="layui-input-block" style="margin: 0 180px">
                                    <input type="text" id="enterprise.name" name="enterprise.name" value="#(organization.name)" class="layui-input " style="width: 300px" lay-verify="required" />
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label" for="enterprise.website" style="width: 180px">企业网站</label>
                                <div class="layui-input-block" style="margin: 0 180px">
                                    <input type="text" id="enterprise.website" name="enterprise.website" value="#(enterprise.website)" class="layui-input" style="width: 300px" />
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label" for="enterprise.scale" style="width: 180px">企业人数</label>
                                <div class="layui-input-block" style="margin: 0 180px">
                                    <input type="number" id="enterprise.scale" name="enterprise.scale" value="#(enterprise.scale)" class="layui-input" style="width: 300px" lay-verify="Length" />
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label" for="enterprise.person" style="width: 180px"><em class="require-mark">*</em>企业法人</label>
                                <div class="layui-input-block" style="margin: 0 180px">
                                    <input type="text" id="enterprise.person" name="enterprise.person" value="#(enterprise.person)" class="layui-input" style="width: 300px" lay-verify="required" />
                                </div>
                            </div>
                            <div class="layui-form-item layui-hide">
                                <label class="layui-form-label" for="enterprise.orgID" style="width: 180px">组织机构编号</label>
                                <div class="layui-input-block" style="margin: 0 180px">
                                    <input type="number" id="enterprise.orgID" name="enterprise.orgID" value="#(organization.id)" />
                                </div>
                            </div>

                        </div>
                    </div>

                    <div class="layui-col-md6">
                        <div class="grid-demo">

                            <div class="layui-form-item">
                                <label class="layui-form-label" for="enterprise.type" style="width: 180px"><em class="require-mark">*</em>主体类型</label>
                                <div class="layui-input-block" style="margin: 0 180px">
                                    <input type="text" id="enterprise.type" name="enterprise.type" value="#(enterprise.type)" class="layui-input" style="width: 300px" lay-verify="required" />
                                </div>
                            </div>

                            <div class="layui-form-item">
                                <label class="layui-form-label" for="enterprise.credit" style="width: 180px"><em class="require-mark">*</em>统一社会信用代码</label>
                                <div class="layui-input-block" style="margin: 0 180px">
                                    <input type="text" id="enterprise.credit" name="enterprise.credit" value="#(enterprise.credit)" class="layui-input" style="width: 300px" lay-verify="required" />
                                </div>
                            </div>

                            <div class="layui-progress layui-hide" style="margin-bottom:10px" lay-showpercent="true" id="upload-progress" lay-filter="upload-progress">
                                <div class="layui-progress-bar layui-bg-green" lay-percent="0%"></div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label" for="enterprise.scope" style="width: 180px"><em class="require-mark">*</em>业务范围</label>
                                <div class="layui-input-block" style="margin: 0 180px">
                                    <input type="text" id="enterprise.scope" name="enterprise.scope" value="#(enterprise.scope)" class="layui-input" style="width: 300px" lay-verify="required" />
                                </div>
                            </div>

                            <div class="layui-form-item">
                                <label class="layui-form-label" for="enterpriseStart" style="width: 180px"><em class="require-mark">*</em>创办日期</label>
                                <div class="layui-input-block" style="margin: 0 180px">
                                    <input type="text" id="enterpriseStart" name="enterprise.start" value="#(enterprise.start)" class="layui-input" style="width: 300px" lay-verify="required" />
                                </div>
                            </div>

                            <div class="layui-form-item">
                                <label class="layui-form-label" for="enterprise.landline" style="width: 180px">座机电话</label>
                                <div class="layui-input-block" style="margin: 0 180px">
                                    <input type="text" id="enterprise.landline" name="enterprise.landline" value="#(enterprise.landline)" class="layui-input" style="width: 300px" />
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <br/>

                <div class="layui-col-md9">
                    <div class="grid-demo">

                        <div class="layui-form-item">
                            <label class="layui-form-label" style="width: 180px"><em class="require-mark">*</em>法人身份证照片</label>
                            <div class="layui-input-block layui-upload" style="align-content: center;">
                                <button type="button" class="layui-btn" id="upload" style="margin: 0 100px"><i
                                        class="layui-icon"></i>上传文件
                                </button>
                                <button type="button" class="layui-btn layui-hide " id="see">查看</button>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label" for="enterprise.capital" style="width: 180px"><em class="require-mark">*</em>注册资本</label>
                            <div class="layui-input-inline">
                                <input type="number" id="enterprise.capital" name="enterprise.capital" value="#(enterprise.capital)" lay-verify="required|mLength" class="layui-input" style="width: 800px">
                            </div>
                            <div class="layui-form-mid layui-word-aux" style="margin:-40px 1000px">元</div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label" for="enterprise.principal" style="width: 180px"><em class="require-mark">*</em>公司负责人</label>
                            <div class="layui-input-block" style="margin: 0 180px">
                                <input type="text" id="enterprise.principal" name="enterprise.principal" value="#(enterprise.principal)" class="layui-input" style="width: 850px" lay-verify="required" />
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label" for="enterprise.phone" style="width: 180px"><em class="require-mark">*</em>公司负责人联系方式</label>
                            <div class="layui-input-block" style="margin: 0 180px">
                                <input type="tel" id="enterprise.phone" name="enterprise.phone" value="#(enterprise.phone)" lay-verify="required|phone" class="layui-input" style="width: 850px" />
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label" for="enterprise.address" style="width: 180px"><em class="require-mark">*</em>公司地址</label>
                            <div class="layui-input-block" style="margin: 0 180px">
                                <input type="text" id="enterprise.address" name="enterprise.address" value="#(enterprise.address)" lay-verify="required" class="layui-input" style="width: 850px" />
                            </div>
                        </div>
                        <div class="layui-form-item layui-form-text">
                            <label class="layui-form-label" for="enterprise.resume" style="width: 1030px;">
                                <h style="margin: 0 50px"><em class="require-mark">*</em>公司简介</h>
                            </label>
                            <div class="layui-input-block">
                                <textarea id="enterprise.resume" name="enterprise.resume" lay-verify="required" placeholder="" class="layui-textarea" cols="100" rows="2" wrap="hard" autocomplete="off" style="width: 1030px">#(enterprise.resume)</textarea>
                            </div>
                        </div>

                        <!--隐藏flag作为界面是否禁用的方法-->
                        <input type="text" id="flag" name="flag" class="layui-input layui-disabled layui-hide" value="#(flag)" required/>

                        <div class="layui-form-item">
                            <div class="layui-input-block" style="margin: 0 180px">
                                <button type="button" class="layui-btn" lay-submit lay-filter="sub" style="position:absolute;left:10%; bottom:0; ">保存</button>
                                <button type="button" class="layui-btn layui-btn-warm" id="reset" style=" position:absolute;right:15%;bottom:0; ">取消</button>
                                <button type="button" class="layui-btn layui-btn-warm layui-hide" id="back">返回</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

#end #define js()
<script type="text/javascript">
    var fileID, fileFromID;
    layui.use(['form', 'layer', 'upload', 'laydate', 'element'], function() {
        var layer = layui.layer,
            $ = layui.jquery,
            form = layui.form,
            element = layui.element,
            laydate = layui.laydate,
            upload = layui.upload;

        laydate.render({
            elem: '#enterpriseStart', //指定元素
            max: 0
        });

        //创建监听函数
        var xhrOnProgress = function(fun) {
            xhrOnProgress.onprogress = fun; //绑定监听
            //使用闭包实现监听绑
            return function() {
                //通过$.ajaxSettings.xhr();获得XMLHttpRequest对象
                var xhr = $.ajaxSettings.xhr();
                //判断监听函数是否为函数
                if(typeof xhrOnProgress.onprogress !== 'function')
                    return xhr;
                //如果有监听函数并且xhr对象支持绑定时就把监听函数绑定上去
                if(xhrOnProgress.onprogress && xhr.upload) {
                    xhr.upload.onprogress = xhrOnProgress.onprogress;
                }
                return xhr;
            }
        }

        upload.render({
            elem: '#upload',
            url: '#(ctxPath)/util/uploadFile',
            accept: 'file',
            exts: 'doc|docx|pdf|png|jpeg|jpg',
            xhr: xhrOnProgress,
            progress: function(value) { //上传进度回调 value进度值
                element.progress('upload-progress', value + '%') //设置页面进度条
            },
            data: {
                description: "法人身份证照片"
            },
            before: function(res) {
                $('#upload-progress').removeClass('layui-hide');
            },
            done: function(res) {
                $('#upload-progress').addClass('layui-hide');
                if(res.code == 0) {
                    $.post('#(ctxPath)/app/organization/upload?fileId=' + res.data.fileId + '&tableName=enterprise&fieldName=法人身份证照片', function(data) {
                        <!--$('.loading-bg').remove();-->
                        fileFromID = data.fileFromID;
                        layer.msg("上传成功");
                        fileID = res.data.fileId;
                        $('#see').removeClass('layui-hide');
                    });
                } else if(res.code == 1) {
                    <!--$('.loading-bg').remove();-->
                    layer.msg("文件上传失败，请重新选择上传！");
                    setTimeout(function() {}, 1000);
                }
            },
            error: function(index, upload) {
                $('#upload-progress').addClass('layui-hide');
                alert("文件上传错误！请重新尝试！");
            }
        });

        form.verify({
            mLength: [
                /^[\S]{0,11}$/, '注册资金不能大于11位'
            ],
            tel: [
                /0\d{2,3}-\d{7,8}/, '座机电话格式为000-00000000'
            ],
            pLength: [
                /^[\S]{0,9}$/, '人数不能大于9位'
            ]
        });

        form.on('submit(sub)', function(data) {
            if(isNaN(parseInt(fileFromID))) {
                layer.msg("您的文件还没有上传,请上传后再提交");
                return false;
            }
            util.sendAjax({
                type: 'POST',
                url: '#(ctxPath)/app/organization/enterpriseProve?fileFromID=' + fileFromID,
                data: $.param(data.field),
                loadFlag: true,
                success: function(data) {
                    window.location.href = '#(ctxPath)/app/organization/prove';
                    return true;
                },
                error: function(data) {
                    console.log(data);
                }
            });
            return false;
        });
    });

    if($('#flag').val() == 1) {
        $(".layui-btn").addClass("layui-hide");
        $(":input").addClass("layui-disabled");
        $(":input").attr("disabled", "disabled");
        $('#back').removeClass('layui-hide').removeClass('layui-disabled').attr("disabled", "");
    }

    $('#back').click(function() {
        history.back();
    });

    $('#reset').click(function() {
        history.back();
    });

    $("#see").click(function() {
        pop_show('查看文件', '#(ctxPath)/util/pdfView?fileID=' + fileID, '', '', function() {});
    });
</script>
#end